Skip to content

Refactor contest type inference and fix JSON serialization#1546

Merged
kenkoooo merged 2 commits into
mainfrom
claude/festive-allen-3girww
Jun 15, 2026
Merged

Refactor contest type inference and fix JSON serialization#1546
kenkoooo merged 2 commits into
mainfrom
claude/festive-allen-3girww

Conversation

@kenkoooo

Copy link
Copy Markdown
Owner

Summary

This PR improves the robustness of contest type classification and fixes JSON serialization to better handle missing data fields.

Key Changes

  • Added _parse_rated_range() function: Extracts rating range parsing logic into a dedicated function that handles both legacy ("~") and new ("-") AtCoder rating range formats. This makes the code more maintainable and resilient to format changes.

  • Refactored infer_contest_type(): Simplified the contest type inference logic by using the new parsing function and threshold-based classification instead of exact string matching. This approach is more flexible and easier to extend.

  • Fixed JSON serialization: Added exclude_none=True to the S3 upload to omit None fields from the JSON output. This prevents the frontend from receiving explicit null values, which it rejects for partial models (e.g., a problem with difficulty but no time model).

Implementation Details

  • The _parse_rated_range() function uses regex to parse rating ranges and returns (lower, upper) tuples, with None representing open upper bounds (e.g., "2000 -" or "All").
  • Contest type classification now uses threshold comparisons on the upper bound rather than exact string matching, making it more resilient to minor format variations.
  • Added clarifying comments explaining the JSON serialization change and the fallback to ID-based classification for unrated contests.

https://claude.ai/code/session_01Hsq4dCo1x9ve8W8inoWxe2

claude added 2 commits June 15, 2026 02:26
AtCoder は contests/archive のレーティング対象範囲表記の区切りを
"~"(例: "1200 ~ ")から "-"(例: "2000 -")へ変更した。
infer_contest_type は "~" 形式の文字列完全一致に依存していたため、
"2000 -" が AGC パターンに一致せず AGC075 以降の AGC が UNRATED 判定となり、
推定対象から除外され problem-models に反映されなくなっていた (#1522)。
ABC/ARC は contest id によるフォールバックがあり除外を免れていたため、
AGC のみが problem-models から欠落していた。

- rate_change を区切り文字・空白に依存せずレーティング範囲としてパースし、
  上限なしは AGC、上限値で NEW_ARC / NEW_ABC / OLD_ABC を判定するよう変更。
  従来の "~" 形式と新しい "-" 形式の双方に対応する。
- 推定できなかったフィールド (slope/intercept/variance 等) を null として
  出力せず省略するよう exclude_none=True を指定。フロントエンドは null を持つ
  モデルを invalid と判定して difficulty を非表示にしていた (#1507, #1545)。

https://claude.ai/code/session_01Hsq4dCo1x9ve8W8inoWxe2
AtCoder がレーティング対象範囲表記の区切りを "~" から "-" へ変更したため
(例: " - 1999", "2000 -", "1200 - 2799")、"~" のみで split していた
getRatedTarget では新形式のコンテストがすべて Unrated 扱いになり、
コンテスト名横の色ドットや「Other Rated」系コンテストの
ABC-Like / ARC-Like / AGC-Like 分類が正しく行われていなかった。
両方の区切り文字を受け付けるよう変更し、テストを追加した。

https://claude.ai/code/session_01Hsq4dCo1x9ve8W8inoWxe2
@kenkoooo kenkoooo merged commit f78ab6f into main Jun 15, 2026
2 checks passed
@kenkoooo kenkoooo deleted the claude/festive-allen-3girww branch June 15, 2026 09:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants